package me.yingjie.common.utils

import com.google.gson.Gson
import me.yingjie.common.data.Task
import java.io.File
import java.time.LocalDateTime
fun writeToFile(
    startTimeList: List<LocalDateTime>,
    finishTimeList: List<LocalDateTime>,
    noteList: List<String>,
    isFinishedList: List<Boolean>,
) {
    val taskList = arrayListOf<Task>()
    val gson = Gson()
    noteList.forEachIndexed { i, _ ->
        taskList.add(
            Task(
                startTimeList[i], finishTimeList[i],
                noteList[i], isFinishedList[i]
            )
        )
    }
    val file = File("today.json")
    file.writeText(
        gson.toJson(taskList), Charsets.UTF_8
    )
}

